import matplotlib.pyplot as plt
import networkx as nx
import PIL
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.image as mpimg
from matplotlib import transforms, image
from scipy import ndimage
#reading images
chicago = image.imread('us/chicago.png')
independence = image.imread('us/independence.png')
first_party = image.imread('us/first-party.png')
bakchod1 = mpimg.imread('us/bakchod1.png')
bakchod2 = mpimg.imread('us/bakchod2.png')
bakchod3 = mpimg.imread('us/bakchod3.png')
hallow = mpimg.imread('us/hallow.png')
hallow2 = mpimg.imread('us/hallow2.png')
diwali = mpimg.imread('us/diwali.png')
grouphug = mpimg.imread('us/group-hug.png')
love = mpimg.imread('us/love.png')
ischool = mpimg.imread('us/ishcool.png')
pix = mpimg.imread('us/pix.png')
# Image URLs for graph nodes
icons = {
"sax": "sax.png",
"rao": "rao.png",
"prade": "prade.png",
"bum":"bum.png",
"home":"home.png"
}
# Load images
images = {k: PIL.Image.open(fname) for k, fname in icons.items()}
# Generate the computer network graph
G = nx.Graph()
G.add_node("sax", image=images["sax"], pos = (0,10))
G.add_node("rao", image=images["rao"],pos = (10,20))
G.add_node("home", image=images["home"],pos = (10,10))
G.add_node("bum", image=images["bum"],pos = (10,0))
G.add_node("prade", image=images["prade"],pos = (20,10))
G.add_edge("sax", "rao", color='lightgreen')
G.add_edge("sax", "bum", color='yellow')
G.add_edge("home", "sax", color='red')
G.add_edge("home", "rao", color='red')
G.add_edge("home", "prade", color='red')
G.add_edge("home", "bum", color='red')
G.add_edge("rao", "prade", color='pink')
G.add_edge("bum", "prade", color='lightgreen')
edges = G.edges()
colors = [G[u][v]['color'] for u,v in edges]
print(colors)
['lightgreen', 'yellow', 'red', 'red', 'pink', 'red', 'red', 'lightgreen']
# Get a reproducible layout and create figure
def make_graph():
pos=nx.get_node_attributes(G,'pos')
fig, ax = plt.subplots(figsize=(10, 10))
# Note: the min_source/target_margin kwargs only work with FancyArrowPatch objects.
# Force the use of FancyArrowPatch for edge drawing by setting `arrows=True`,
# but suppress arrowheads with `arrowstyle="-"`
nx.draw_networkx_edges(
G,
pos=pos,
ax=ax,
arrows=True,
arrowstyle="-",
min_source_margin=15,
min_target_margin=15,
width=5,
edge_color=colors,
style="solid",
node_shape="o"
)
# Transform from data coordinates (scaled between xlim and ylim) to display coordinates
tr_figure = ax.transData.transform
# Transform from display to figure coordinates
tr_axes = fig.transFigure.inverted().transform
# Select the size of the image (relative to the X axis)
icon_size = (ax.get_xlim()[1] - ax.get_xlim()[0]) * 0.0025
icon_center = icon_size / 2.0
# Add the respective image to each node
for n in G.nodes:
xf, yf = tr_figure(pos[n])
xa, ya = tr_axes((xf, yf))
# get overlapped axes and plot icon
a = plt.axes([xa - icon_center, ya - icon_center, icon_size, icon_size])
a.imshow(G.nodes[n]["image"])
a.axis("off")
plt.show()
This is a series of network graphs which will update the strengths of our relationships, eventually turning into the family that we are! Lets start with an inital network graph!
make_graph()
Let's start with when we were casually filling google forms, bonding on barcelona, discussing visa (HAIL PANKIL!), anime and just getting to know each other! Bakchodi toh day 1 se thi, aise hi thodi $1000 ka amazon coupon le liya tha Michael se ;) Forward to Independence day, Chicago and our first ever party here our first ever picture!
plt.figure(figsize=(12,16))
plt.axis("off")
plt.imshow(ndimage.rotate(independence,270))
plt.show()
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
plt.figure(figsize=(12,16))
plt.axis("off")
plt.imshow(chicago)
plt.show()
plt.figure(figsize=(12,16))
plt.axis("off")
plt.imshow(first_party)
plt.show()
You were the last one to come here but you sure made it a point the Friday Lord bonds us well. Let's look at the updated status of our network graph!
colors[1] = 'lightgreen'
# colors[6] = 'lightgreen'
colors[2] = 'pink'
colors[3] = 'pink'
colors[4] = 'lightgreen'
colors[5] = 'pink'
colors[6] = 'pink'
make_graph()
Festivals only bought us closer, we'll let matplotlib help us travel through the memory lane!
plt.figure(figsize=(12,16))
plt.axis("off")
plt.imshow(ndimage.rotate(hallow,270))
plt.show()
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
plt.figure(figsize=(12,16))
plt.axis("off")
plt.imshow(hallow2)
plt.show()
plt.figure(figsize=(12,16))
plt.axis("off")
plt.imshow(diwali)
plt.show()
Zenitsu, Tanjiro, Kyojiro and Giyu had bonded damn well till then. Many fuck ups and laughs later...
colors[2] = 'lightgreen'
colors[3] = 'lightgreen'
colors[5] = 'lightgreen'
colors[6] = 'lightgreen'
make_graph()
plt.figure(figsize=(12,16))
plt.axis("off")
plt.imshow(ndimage.rotate(grouphug,270))
plt.show()
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
plt.figure(figsize=(12,16))
plt.axis("off")
plt.imshow(ndimage.rotate(love,270))
plt.show()
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
plt.figure(figsize=(12,16))
plt.axis("off")
plt.imshow(ischool)
plt.show()
home feels complete, so should the network graph right?
for i in range(0, len(colors)):
colors[i] = 'darkgreen'
make_graph()
Knowing that you are a sucker for heatmaps, want to see one tailored just for you?
file = pd.ExcelFile('home305.xlsx')
names = file.sheet_names # see all sheet names
df = pd.concat([file.parse(name) for name in names])
x_values = [df.x1, df.x2]
y_values = [df.y1, df.y2]
rao_heatmap = np.zeros((140,100))
#updating heat values
#rao room
for x in range (110,140):
for y in range (60, 100):
rao_heatmap[x][y] = 0.65
#rao bed
for x in range (120,140):
for y in range (80,100):
rao_heatmap[x][y] = 0.75
for x in range (125,135):
for y in range (85,95):
rao_heatmap[x][y] = 0.85
for x in range (128,132):
for y in range (88,92):
rao_heatmap[x][y] = 0.95
#hallway
for x in range (30,140):
for y in range (50,60):
rao_heatmap[x][y] = 0.35
#bathroom
#main
for x in range (90,110):
for y in range (60,100):
rao_heatmap[x][y] = 0.45
#pot
for x in range (90,95):
for y in range (70,75):
rao_heatmap[x][y] = 0.6
#other
for x in range (60,80):
for y in range (60,100):
rao_heatmap[x][y] = 0.2
#pot
for x in range (75,80):
for y in range (70,75):
rao_heatmap[x][y] = 0.35
#Kitchen
#non-walkable
for x in range (30,60):
for y in range (60,100):
rao_heatmap[x][y] = 0.05
#walkable
for x in range (42,48):
for y in range (60,100):
rao_heatmap[x][y] = 0.4
#Hall
for x in range (0,30):
for y in range (10,100):
rao_heatmap[x][y] = 0.4
#dining table
for x in range (15,25):
for y in range (75,95):
rao_heatmap[x][y] = 0.5
#couches
for x in range (0,10):
for y in range (15,25):
rao_heatmap[x][y] = 0.65
for x in range (0,10):
for y in range (35,65):
rao_heatmap[x][y] = 0.65
#balcony
for x in range (10,20):
for y in range (5,10):
rao_heatmap[x][y] = 0.3
#sax room
for x in range (80,110):
for y in range (10,50):
rao_heatmap[x][y] = 0.2
#prade room
for x in range (110,140):
for y in range (10,50):
rao_heatmap[x][y] = 0.15
#bum room
for x in range (30,60):
for y in range (10,50):
rao_heatmap[x][y] = 0.1
plt.figure(figsize=(12,16))
plt.xlim(-10, 110), plt.ylim(0, 140)
plt.plot(x_values, y_values,'black')
plt.imshow(rao_heatmap, zorder=0, aspect="auto", extent=(0,100,0,140),cmap='hot_r', origin = 'lower')
plt.axis("off")
plt.title("Aaditya Rao's Heatmap for 506 S Fourth - 305",fontsize = 40)
plt.show()
plt.figure(figsize=(12,16))
plt.axis("off")
plt.imshow(ndimage.rotate(pix,270))
plt.show()
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).